//package com.gongyibao.gbase.config;
//
//import com.alicp.jetcache.anno.CacheConsts;
//import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
//import com.alicp.jetcache.anno.config.EnableMethodCache;
//import com.alicp.jetcache.anno.support.GlobalCacheConfig;
//import com.alicp.jetcache.anno.support.JetCacheBaseBeans;
//import com.alicp.jetcache.embedded.EmbeddedCacheBuilder;
//import com.alicp.jetcache.embedded.LinkedHashMapCacheBuilder;
//import com.alicp.jetcache.redis.RedisCacheBuilder;
//import com.alicp.jetcache.support.Fastjson2KeyConvertor;
//import com.alicp.jetcache.support.JavaValueDecoder;
//import com.alicp.jetcache.support.JavaValueEncoder;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Import;
//import redis.clients.jedis.Jedis;
//import redis.clients.jedis.util.Pool;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @Author: 张启峰
// * @Date: 2023/4/18 17:27
// * @Description: gyb-
// */
//@Configuration
//@EnableMethodCache(basePackages = "com.company.mypackage")
//@EnableCreateCacheAnnotation
//@Import(JetCacheBaseBeans.class) //need since jetcache 2.7+
//public class JetCacheConfig {
//
//    @Bean
//    public Pool<Jedis> pool() {
//        // build jedis pool ...
//    }
//
//    //@Bean for jetcache <=2.6
//    //public SpringConfigProvider springConfigProvider() {
//    //    return new SpringConfigProvider();
//    //}
//
//    @Bean
//    public GlobalCacheConfig config(Pool<Jedis> pool) {
//        Map localBuilders = new HashMap();
//        EmbeddedCacheBuilder localBuilder = LinkedHashMapCacheBuilder
//                .createLinkedHashMapCacheBuilder()
//                .keyConvertor(Fastjson2KeyConvertor.INSTANCE);
//        localBuilders.put(CacheConsts.DEFAULT_AREA, localBuilder);
//
//        Map remoteBuilders = new HashMap();
//        RedisCacheBuilder remoteCacheBuilder = RedisCacheBuilder.createRedisCacheBuilder()
//                .keyConvertor(FastjsonKey2Convertor.INSTANCE)
//                .valueEncoder(JavaValueEncoder.INSTANCE)
//                .valueDecoder(JavaValueDecoder.INSTANCE)
//                .broadcastChannel("projectA")
//                .jedisPool(pool);
//        remoteBuilders.put(CacheConsts.DEFAULT_AREA, remoteCacheBuilder);
//
//        GlobalCacheConfig globalCacheConfig = new GlobalCacheConfig();
//        globalCacheConfig.setLocalCacheBuilders(localBuilders);
//        globalCacheConfig.setRemoteCacheBuilders(remoteBuilders);
//        globalCacheConfig.setStatIntervalMinutes(15);
//        globalCacheConfig.setAreaInCacheName(false);
//
//        return globalCacheConfig;
//    }
//}
